//
//  HugeAmountsBuyersViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/5.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "HugeAmountsBuyersViewModel.h"
#import "HugeAmountsBuyersTableViewCell.h"
#import "GoodsOrStoreNavView.h"
#import "GoodsTopSelectView.h"
#import "AdressAndSortingView.h"
#import "ScreeningView.h"

@interface HugeAmountsBuyersViewModel ()<UITableViewDelegate,UITableViewDataSource,GoodsTopDelegate>{
    UIView * selfView;
    AdressAndSortingView * screeningView;
    ScreeningView * screenView;
    GoodsTopSelectView * topSelectView;
}
@end

@implementation HugeAmountsBuyersViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        selfView = superView;
        tableView.y = tableView.y + kHeightProportion_In_iPhoneTriploid(78);//34 + 44
        tableView.height = tableView.height - kHeightProportion_In_iPhoneTriploid(78);
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10))];
        tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(10))];
        [superView addSubview:tableView];
        //
        [self createSearchView];
    }
    return self;
}
-(void)createSearchView{
    GLGWView * searchBankgroundView = [[GLGWView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(44)) inSuperView:selfView];
    searchBankgroundView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
    GoodsOrStoreNavView * searchView = [[GoodsOrStoreNavView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(35), kHeightProportion_In_iPhoneTriploid(7), KScreenWidth - kWidthProportion_In_iPhoneTriploid(70), kHeightProportion_In_iPhoneTriploid(30))];
    [searchBankgroundView addSubview:searchView];
    //
    topSelectView = [[GoodsTopSelectView alloc] initWithFrame:CGRectMake(0, kY_With_View(searchBankgroundView, 0), KScreenWidth, kHeightProportion_In_iPhoneTriploid(34)) inSuperView:selfView];
    topSelectView.delegate = self;
}

#pragma mark --- UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return kHeightProportion_In_iPhoneTriploid(184);
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HugeAmountsBuyersTableViewCell * cell = [HugeAmountsBuyersTableViewCell cellWithTableView:tableView];
    return cell;
}

#pragma mark ----- GoodsTopDelegate
-(void)selectTopViewButTag:(NSInteger)tag_num{
    if (screenView || screeningView) {
        [screeningView dissmiss];
        [screenView dissmiss];
    }
    switch (tag_num) {
        case 180:{
            screeningView = [[AdressAndSortingView alloc] initWithFrame:CGRectMake(0, kY_With_View(topSelectView, 1), KScreenWidth, KScreenHeight - kHeightProportion_In_iPhoneTriploid(35)) theTableListType:ListType_AllAdress inSuperView:selfView];
        }
            break;
        case 181:{
            screeningView = [[AdressAndSortingView alloc] initWithFrame:CGRectMake(0, kY_With_View(topSelectView, 1), KScreenWidth, KScreenHeight - kHeightProportion_In_iPhoneTriploid(35)) theTableListType:ListType_Comprehensive inSuperView:selfView];
        }
            break;
        case 182:{
            CGFloat sc_height;
            if (iPhoneX) {
                sc_height = KScreenHeight - kHeightProportion_In_iPhoneTriploid(78) - 88 - kHeightProportion_In_iPhoneTriploid(34);
            }else{
                sc_height = KScreenHeight - kHeightProportion_In_iPhoneTriploid(78) - 64;
            }
            screenView = [[ScreeningView alloc] initWithFrame:CGRectMake(0, kY_With_View(topSelectView, 1), KScreenWidth, sc_height) inSuperView:selfView];
            
        }
            break;
            
        default:
            break;
    }
}

@end
